package com.qfedu.controller;


import com.qfedu.fmmall.service.CategoryService;
import com.qfedu.fmmall.service.IndexImgService;
import com.qfedu.fmmall.service.ProductService;
import com.qfedu.fmmall.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/index")
@Api(tags = "主页管理",value = "提供首页数据所需的接口")
public class IndexController {

    @Autowired
    private IndexImgService indexImgService;

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private ProductService productService;

    @GetMapping("/indexImg")
    @ApiOperation("获取首页轮播图")
    public ResultVo getIndexImg(){
        return indexImgService.listIndexImgs();
    }

    @GetMapping("/categorylist")
    @ApiOperation("获取首页分类")
    public ResultVo getCategotyList(){
        return categoryService.listCategories();
    }

    @GetMapping("/list-recommends")
    @ApiOperation("获取推荐商品")
    public ResultVo getRecommends(){
        return productService.listRecommendProducts();
    }

    @GetMapping("/list-firstProdust")
    @ApiOperation("获取分类推荐商品")
    public ResultVo getFistProdust(){
        return categoryService.selectFirstLevelCategories();
    }
}
